"""elastic URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""

from django.contrib import admin
from django.urls import include, path, re_path
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.views.static import serve
from django.conf import settings

from rest_framework_swagger.views import get_swagger_view

schema_view = get_swagger_view(title='CRUD API')

urlpatterns = [
    path('doc', schema_view),
    path('admin/', admin.site.urls),

    # media配置
    #     1、setting配置目录
    #     2、新建目录
    #     3、url中配置路径
    #     4、访问 http://127.0.0.1:8000/media/img/default.jpg
    re_path('media/(?P<path>.*)', serve, {'document_root': settings.MEDIA_ROOT}),


    # 02-序列化功能
    # 路由分发
    # path('api/v1/command/', include('apps.command.urls'), name='command'),
    # path('api/v1/foreignkey/', include('apps.foreignkey.urls'), name='foreignkey'),
    # path('api/v1/template-bak-test/', include('apps.template-bak-test.urls'), name='template-bak-test'),

    # 03-view家族
    path('api/v1/foreignkey/', include('apps.foreignkey.urls'), name='foreignkey'),

]

urlpatterns += staticfiles_urlpatterns()
